package vinylInt
{
	import flash.events.*;
	import flash.display.MovieClip;
	import flash.utils.getDefinitionByName;

	/**
	 * 
	 */
	public class vinylIntButton extends MovieClip
	{
		public var _deepLink = '//';
		public var value:Boolean = false;
		
		[Inspectable(defaultValue="//", type=String)] 
		public function set deepLink( str:String ):void{
			_deepLink= str; 
		} 
		public function get deepLink():String{
			return _deepLink; 
		}
		
		public function vinylIntButton() 
		{	
			super();
			buttonMode = true;
			stop();
			
			init();
		}
		
		public function init()
		{
			addEventListener( MouseEvent.CLICK, handler );
			addEventListener( MouseEvent.ROLL_OVER, handler );
			addEventListener( MouseEvent.ROLL_OUT, handler );
		}
		
		function handler( e ):void
		{
			switch( e.type )
			{
				case "rollOver":
					removeEventListener( Event.ENTER_FRAME, enterFrameHandler );
					if( e.currentTarget.currentFrame == 1 ) e.currentTarget.gotoAndPlay( 2 );
					else  e.currentTarget.gotoAndPlay( e.currentTarget.currentFrame + 1 );
				break;
				
				case "rollOut":
					addEventListener( Event.ENTER_FRAME, enterFrameHandler );
				break;
		
				case "click":
					//e.currentTarget.click.gotoAndPlay( 2 );
					e.currentTarget.gotoAndPlay( 2 );
					( root as Object ).button_click( e )
				break;
			}
		}
		
		private function enterFrameHandler(e)
		{
			e.currentTarget.prevFrame();
			if( e.currentTarget.currentFrame == 1 ) 
			{
				removeEventListener( Event.ENTER_FRAME, enterFrameHandler );
			}
		}
	}
}